package com.sunsy.authserver.wrapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 包装工具类 PO VO DTO
 *
 * @author kaili
 * @date 2020/6/18
 */
//public abstract class AbstractWrapper<P extends BasePO, V extends BaseVO, D extends BaseDTO> {
public abstract class AbstractWrapper<P, V, D> {

//  public AbstractWrapper(){}

  public abstract QueryWrapper<P> dto2QWrapper(D dto);

  public abstract P dto2PO(D dto);

  public abstract V po2VO(P po);

  public List<V> poList2VO(List<P> poList) {
    return poList.stream().map(this::po2VO).collect(Collectors.toList());
  }

  public IPage<V> poPage2VO(IPage<P> pages) {
    return pages.convert(this::po2VO);
  }

}
